package com.company.task1;

/*
1. 编程题

 编程统计字符串"ABCD123!@#$%ab"中大写字母、小写字母、数字、其它字符的个数并打 印出来。
 */

public class CountString {

    public static void main(String[] args) {

        int numUpper = 0;
        int numLower = 0;
        int numNumber = 0;
        int numOthers = 0;
        int i;
        int asc;

        String s = "ABCD123!@#$%ab";

        for(i = 0; i < s.length(); i++){
            asc = s.charAt(i);
            if(asc >= 97 && asc <= 122) numLower ++;
            else if(asc >= 65 && asc <= 90) numUpper ++;
            else if(asc >= 48 && asc <= 57) numNumber++;
            else numOthers++;
        }

        System.out.println("大写字母数：" + numUpper);
        System.out.println("小写字母数：" + numLower);
        System.out.println("数字数：" + numNumber);
        System.out.println("其他字符数：" + numOthers);
    }
}
